import { Observer } from "mobx-vue"
import { Component, Vue } from "vue-property-decorator";
require('./tabNav.scss')

@Observer
@Component({
    props: {
        content: { //tab项数据
            type: Array,
            default: []
        },
        tabIndex: { //tab项总数 （可选参数）
            type: Array,
            default: () => {
                return []
            }
        },
        selected: { //高亮项
            type: Number,
            default: 0
        }
    }
})
export default class TabNav extends Vue {
    tabSelected: any = 0;

    mounted() {
        let vm: any = this;
        vm.tabSelected = vm.selected;
    }

    tabClick(item, index) {
        let vm: any = this;
        //防止重复点击
        if (vm.tabSelected == index) {
            vm.$emit('tabClick', item, false);
        } else {
            vm.$emit('tabClick', item, true);
        }
        vm.tabSelected = index;

    }
    onTabClick(index) {
        let vm: any = this;
        vm.tabSelected = index;

    }
}
